#region [file: ContaBancariaDAL.cs, author: Lucas Bittencourt]
// File:    ContaBancariaDAL.cs
// Author:  Lucas Bittencourt
// Created: terça-feira, 25 de outubro de 2011 09:26:29
// Purpose: Defines dao implementation class for class ContaBancaria
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using NHibernate.Criterion;
using DA_OOMModel;
using DA_OOMModelIDAL;

namespace DA_OOMNHibernateDAL
{
   /// <summary>
   /// Class that implements methods of IContaBancariaDAL interface
   /// </summary>
   public class ContaBancariaDAL : NHibernateDALBase,  IContaBancariaDAL 
   {
      #region CRUD methods
      /// <summary>
      /// Get all instances of ContaBancaria
      /// </summary>     
      public List<ContaBancaria> GetContaBancariaList()
      {
         return ConvertToGenericList(base.LoadAll(typeof(ContaBancaria)));
      }
      
      /// <summary>
      /// Get the instances of ContaBancaria from index firstResult to index maxResult
      /// </summary>
      public List<ContaBancaria> GetContaBancariaList(int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.LoadAll(typeof(ContaBancaria), firstResult, maxResult));
      }

      /// <summary>
      /// Load the instance of ContaBancaria according its primary key instance.
      /// </summary>
      public ContaBancaria Load(ContaBancariaPK contaBancariaPK)
      {
         IList cs = new ArrayList();
         string[] paramNames = new string[] { "CnbIdConta" };
         object[] values = new object[] { contaBancariaPK.CnbIdConta };
         for (int i = 0; i < paramNames.Length; i++)
             cs.Add(Expression.Eq(paramNames[i], values[i]));

         IList list = base.FindByCriterions(typeof(ContaBancaria), cs);
         return (((list != null) && (list.Count > 0)) ? (ContaBancaria)list[0] : null);
      }

      /// <summary>
      /// Query the instances of ContaBancaria according its example instance.
      /// </summary>
      public List<ContaBancaria> QueryByExample(ContaBancaria contaBancaria)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(ContaBancaria), contaBancaria));
      }

      /// <summary>
      /// Query the instances of ContaBancaria according its example instance from index firstResult to index maxResult
      /// </summary>
      public List<ContaBancaria> QueryByExample(ContaBancaria contaBancaria, int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(ContaBancaria), contaBancaria, firstResult, maxResult));
      }
      
      /// <summary>
      /// Insert the instances of ContaBancaria
      /// </summary>
      public void Insert(ContaBancaria contaBancariaObject)
      {
         base.Save(contaBancariaObject);
      }
      
      /// <summary>
      /// Update the instances of ContaBancaria
      /// </summary>
      public void Update(ContaBancaria contaBancariaObject)
      {
         base.Update(contaBancariaObject);
      }
      
      /// <summary>
      /// Delete the instances of ContaBancaria
      /// </summary>
      public void Delete(ContaBancaria contaBancariaObject)
      {
         base.Delete(contaBancariaObject);
      }
      #endregion
      
   
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbTpProprietario
      /// </summary>
      public List<ContaBancaria> FindByCnbTpProprietario(string cnbTpProprietario) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbTpProprietario", cnbTpProprietario));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbTpProprietario, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbTpProprietario(string cnbTpProprietario, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbTpProprietario", cnbTpProprietario));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbDsConta
      /// </summary>
      public List<ContaBancaria> FindByCnbDsConta(string cnbDsConta) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbDsConta", cnbDsConta));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbDsConta, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbDsConta(string cnbDsConta, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbDsConta", cnbDsConta));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbNuConta
      /// </summary>
      public List<ContaBancaria> FindByCnbNuConta(string cnbNuConta) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbNuConta", cnbNuConta));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbNuConta, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbNuConta(string cnbNuConta, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbNuConta", cnbNuConta));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbNuDigitoConta
      /// </summary>
      public List<ContaBancaria> FindByCnbNuDigitoConta(string cnbNuDigitoConta) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbNuDigitoConta", cnbNuDigitoConta));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbNuDigitoConta, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbNuDigitoConta(string cnbNuDigitoConta, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbNuDigitoConta", cnbNuDigitoConta));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbVlSaldoInicial
      /// </summary>
      public List<ContaBancaria> FindByCnbVlSaldoInicial(decimal cnbVlSaldoInicial) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbVlSaldoInicial", cnbVlSaldoInicial));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbVlSaldoInicial, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbVlSaldoInicial(decimal cnbVlSaldoInicial, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbVlSaldoInicial", cnbVlSaldoInicial));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbCdVariacao
      /// </summary>
      public List<ContaBancaria> FindByCnbCdVariacao(string cnbCdVariacao) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbCdVariacao", cnbCdVariacao));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbCdVariacao, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbCdVariacao(string cnbCdVariacao, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbCdVariacao", cnbCdVariacao));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbDtAbertura
      /// </summary>
      public List<ContaBancaria> FindByCnbDtAbertura(DateTime cnbDtAbertura) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbDtAbertura", cnbDtAbertura));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find the instances of ContaBancaria according to its attribute cnbDtAbertura, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<ContaBancaria> FindByCnbDtAbertura(DateTime cnbDtAbertura, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("CnbDtAbertura", cnbDtAbertura));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs, firstResult, maxResult));
      }
      
      /// <summary>
      /// Find <Code>ContaBancaria</Code> instances by Cliente
      /// </summary>
      /// <param name="cliente"/>
      /// <returns>ContaBancaria instance list</returns>
      public List<ContaBancaria> FindByCliente(Cliente cliente)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Cliente", cliente));
         return ConvertToGenericList(base.FindByCriterions(typeof(ContaBancaria), cs));
      }
      
      /// <summary>
      /// Find <Code>ContaBancaria</Code> instances  instances in range firstResult, maxResult by Cliente
      /// </summary>
      /// <param name="cliente"/>
      /// <param name="firstResult">first result to return</param>
      /// <param name="maxResult">max result to return</param>
      /// <returns>ContaBancaria instance list</returns>
      public List<ContaBancaria> FindByCliente(Cliente cliente, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Cliente", cliente));
         return ConvertToGenericList(base.FindByCriterions(typeof(Cliente), cs, firstResult, maxResult));
      }
      
      /// <summary>
      /// Find <Code>ContaBancaria</Code> instances by Agencia
      /// </summary>
      /// <param name="agencia"/>
      /// <returns>ContaBancaria instance list</returns>
      public List<ContaBancaria> FindByAgencia(Agencia agencia)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Agencia", agencia));
         return ConvertToGenericList(base.FindByCriterions(typeof(Agencia), cs));
      }
      
      /// <summary>
      /// Find <Code>ContaBancaria</Code> instances  instances in range firstResult, maxResult by Agencia
      /// </summary>
      /// <param name="agencia"/>
      /// <param name="firstResult">first result to return</param>
      /// <param name="maxResult">max result to return</param>
      /// <returns>ContaBancaria instance list</returns>
      public List<ContaBancaria> FindByAgencia(Agencia agencia, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Agencia", agencia));
         return ConvertToGenericList(base.FindByCriterions(typeof(Agencia), cs, firstResult, maxResult));
      }
      
      /// <summary>
      /// Find <Code>ContaBancaria</Code> instances by Empresa
      /// </summary>
      /// <param name="empresa"/>
      /// <returns>ContaBancaria instance list</returns>
      public List<ContaBancaria> FindByEmpresa(Empresa empresa)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Empresa", empresa));
         return ConvertToGenericList(base.FindByCriterions(typeof(Empresa), cs));
      }
      
      /// <summary>
      /// Find <Code>ContaBancaria</Code> instances  instances in range firstResult, maxResult by Empresa
      /// </summary>
      /// <param name="empresa"/>
      /// <param name="firstResult">first result to return</param>
      /// <param name="maxResult">max result to return</param>
      /// <returns>ContaBancaria instance list</returns>
      public List<ContaBancaria> FindByEmpresa(Empresa empresa, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Empresa", empresa));
         return ConvertToGenericList(base.FindByCriterions(typeof(Empresa), cs, firstResult, maxResult));
      }

      /// <summary>
      /// Convert the IList to the generic List instance.
      /// </summary>
      private List<ContaBancaria> ConvertToGenericList(IList contaBancarias)
      {
         List<ContaBancaria> contaBancariaList = new List<ContaBancaria>();
         foreach (ContaBancaria contaBancaria in contaBancarias)
         {
             contaBancariaList.Add(contaBancaria);
         }
         return contaBancariaList;
      }      
   }
}